﻿#include "coupler/coupler.h"
#include "global.h"
#include "plugin_export.h"
#include "plugin_info.h"
#include "plugin_typedef.h"

#include <sstream>

int authCode = 0;

int LoadingInfo(int session) {
    authCode = Api_Initialize(session, info_json_str);
    return authCode;
}

int EventInit(char* path) {
    Api_SetFatal(authCode);
    Api_AppendLogs(authCode, "CppDemo EventInit");
    return RET_TYPE_IGNORE;
}

int EventEnable() {
    return RET_TYPE_IGNORE;
}

int EventStop(int type) {
    return RET_TYPE_IGNORE;
}

int EventLogin(LPCSTR robot_wxid, LPCSTR robot_name, int type, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMsg(LPCSTR robot_wxid, int type, LPCSTR from_wxid, LPCSTR from_name, LPCSTR final_from_wxid,
                  LPCSTR final_from_name, LPCSTR to_wxid, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventFriendMsg(LPCSTR robot_wxid, int type, LPCSTR from_wxid, LPCSTR from_name, LPCSTR to_wxid,
                   LPCSTR msg) {
    if (type == MSG_TYPE_TEXT) {
        std::ostringstream omsg;
        omsg << "Received message \"" << msg << "\" from " << from_name;
        Api_SendTextMsg(authCode, robot_wxid, from_wxid, omsg.str().c_str());
        Api_AppendLogs(authCode, omsg.str().c_str());
    }
    return RET_TYPE_IGNORE;
}

int EventReceivedTransfer(LPCSTR robot_wxid, LPCSTR from_wxid, LPCSTR from_name, LPCSTR to_wxid, LPCSTR money,
                          LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

int EventScanCashMoney(LPCSTR robot_wxid, LPCSTR pay_wxid, LPCSTR pay_name, LPCSTR money, LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

int EventFriendVerify(LPCSTR robot_wxid, LPCSTR from_wxid, LPCSTR from_name, LPCSTR to_wxid,
                      LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

int EventContactsChange(LPCSTR robot_wxid, int type, LPCSTR from_wxid, LPCSTR from_name, LPCSTR msg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMemberAdd(LPCSTR robot_wxid, LPCSTR from_wxid, LPCSTR from_name, LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

int EventGroupMemberDecrease(LPCSTR robot_wxid, LPCSTR from_wxid, LPCSTR from_name, LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

int EventSysMsg(LPCSTR robot_wxid, int type, LPCSTR json_msg) {
    return RET_TYPE_IGNORE;
}

void Menu() {
    MessageBoxA(NULL, "Hello!", "Menu", MB_OK);
}
